# 通用函数
# https://www.bilibili.com/video/BV19T4y127Z2/?p=3&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
import numpy as np

print("common functions")

print("# ############################################")
# 角度
angles = np.array([0, 30, 45, 60, 90])
radians = angles * np.pi / 180
print(radians)

# 角度 -> 弧度
radians2 = np.radians(angles)
print(radians2)

# 三角函数（输入需要弧度制）
print(np.sin(radians2))
print(np.cos(radians2))
print(np.tan(radians2))
print(np.arcsin(np.sin(radians2)))

# 弧度 -> 角度
degrees = np.degrees(radians)
print(degrees)


print("# ############################################")
nums = np.array([12.34, 23.76, 34.35, 36.11, 65.23, 98.23, 36.44, 57.56, 81.44, 45.01])
print(nums)
# 平均值
print(np.mean(nums))
# 中位数
print(np.median(nums))
# 标准差
print(np.std(nums))
# 25分位数， 75分位数
print(np.percentile(nums, 25))
print(np.percentile(nums, 75))
print(np.percentile(nums, 50))


print("# ############################################")
# 读文件
salaries = np.genfromtxt("../resources/salary.csv", delimiter=",")
print(salaries)
# 数字特征：
# 平均值
print(np.mean(salaries))
# 中位数
print(np.median(salaries))
# 标准差
print(np.std(salaries))
# 方差
print(np.var(salaries))